﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MaxLeaf.Common;
using MaxLeaf.DB;
using System.Data;
using MySql.Data.MySqlClient;
using System.Data.SqlClient;
 

namespace MaxLeaf.DAL.Web2SCP
{
   

    public class goods_unit_groupDAL : BaseDAL
    {
        public goods_unit_groupDAL()
            : base()
        {
            strSCPTableName = "goods_unit_group";
            strWebTableName = "goods_unit_group";

            strSCPKeyFieldName = "unit_group_id";
            strWebKeyFieldName = "unit_group_id";





            strFieldNames = "group_name,is_delete,create_time,update_time";
 
        }
        public override int Update(DBAccess dbOrgWebReadCon, DBAccess dbOrgWebWriteCon, DBAccess dbDestSCPCon, string strKeyValue)
        {
            int intDestKeyValue = base.Update(dbOrgWebReadCon, dbOrgWebWriteCon, dbDestSCPCon, strKeyValue);

            KeyValuePair<string, IDataParameter[]> kvp = dbOrgWebReadCon.CreateCondParam(new Dictionary<string, object>() { { "unit_group_id", strKeyValue } });
            DataTable dtOrgData = dbOrgWebReadCon.GetDataTable(string.Format("select * from goods_measure_unit where {0}", kvp.Key ), kvp.Value);
            foreach (DataRow drOrgData in dtOrgData.Rows)
            {
                new goods_measure_unitDAL().Update(dbOrgWebReadCon, dbOrgWebWriteCon, dbDestSCPCon, CvtFunc.ToString(drOrgData["measure_unit_id"]));
            }

            return intDestKeyValue;
        }
              
    }
}